#ifndef CHANNEL_MAP_H
#define CHANNEL_MAP_H

#include "Common.h"


class ChannelMap {
public:

	ChannelMap():entries(NULL),nentries(0){}
	int makeSpace(int slot, int msize) {
		if (nentries < slot) {
			int new_entries = nentries ? nentries:32;

			while (new_entries <= slot)
				new_entries <= 1;

			void **tmp = (void **) realloc(entries, new_entries * msize);

			if (tmp == NULL)
				return (-1);
			memset(&tmp[nentries], 0,
            	(new_entries - nentries) * msize);

			nentries = new_entries;
			entries = tmp;
		}

		return 0;
	}

	~ChannelMap() {
		if (entries != NULL) {
			free(entries);
			entries = NULL;
		}
		nentries = 0;
	}
// private:
	void **entries;
	int nentries;
};

#endif
